@use '../variables';

$block: '.#{variables.$ns}sheet';

#{$block} {
    position: fixed;
    inset-block-start: 0;
    inset-inline-start: 0;
    width: 100%;
    height: 100%;
    z-index: 100000;

    $top-height: 20px;
    $transition-duration: 0.3s;

    &__veil {
        position: absolute;
        inset-block-start: 0;
        inset-inline-start: 0;
        height: 100%;
        width: 100%;
        background-color: var(--g-color-sfx-veil);
        opacity: 0;
        will-change: opacity;

        &_with-transition {
            transition: opacity $transition-duration ease;
        }
    }

    &__sheet {
        position: absolute;
        inset-block-start: 100%;
        inset-inline-start: 0;
        width: 100%;
        max-height: 100%;
        will-change: transform;

        &_with-transition {
            transition: transform $transition-duration ease;
        }

        @media (prefers-reduced-motion: reduce) {
            opacity: 0;

            &_with-transition {
                transition: opacity $transition-duration ease;
            }
        }
    }

    &__sheet-swipe-area {
        position: absolute;
        inset-block-start: -20px;
        inset-inline-start: 0;
        width: 100%;
        height: 40px;
        z-index: 1;
    }

    &__sheet-top {
        position: relative;
        height: $top-height;
        border-start-start-radius: 20px;
        border-start-end-radius: 20px;
        background-color: var(--g-sheet-background-color, var(--g-color-base-float));
    }

    &__sheet-top-resizer {
        --_--translate-x: calc(-50% * var(--g-flow-direction));
        position: absolute;
        inset-block-start: 50%;
        inset-inline-start: 50%;
        transform: translateX(var(--_--translate-x)) translateY(-50%);
        width: 40px;
        height: 4px;
        border-radius: 4px;
        background-color: var(--g-color-line-generic);
    }

    &__sheet-scroll-container {
        box-sizing: border-box;
        max-height: calc(100% - #{$top-height});
        overflow: hidden auto;
        overscroll-behavior-y: contain;
        background-color: var(--g-sheet-background-color, var(--g-color-base-float));

        transition: height $transition-duration ease;

        &_without-scroll {
            overflow: hidden;
        }

        @media (prefers-reduced-motion: reduce) {
            transition-duration: 1ms;
        }
    }

    &__sheet-margin-box {
        // prevents margin escape from container
        border: 1px solid transparent;

        &_always-full-height {
            box-sizing: border-box;
            height: 100%;

            #{$block}__sheet-margin-box-border-compensation {
                height: 100%;
            }
        }
    }

    &__sheet-margin-box-border-compensation {
        // compensate for border of margin box
        margin: -1px;
    }

    &__sheet-content {
        box-sizing: border-box;
        width: 100%;
        padding: var(--g-sheet-content-padding, 0 10px);
    }

    &__sheet-content-title {
        padding-block-end: 8px;
        font-size: var(--g-text-body-2-font-size);
        line-height: 28px;
        text-align: center;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }
}
